<?php

class DetalleAccidente extends DBAbstractModel {
    
    public $status_persona;
    public $id_accidente;
    public $cedula_persona;
    public $placa_vehiculo;
    public $roles;
    public $medicos_id_medico;
    public $citas_peritos_id_cita;
    public $remolques_id_remolque;
    
    function save() {
        $this->query = '';
        $this->query = "INSERT INTO detalle_accidentes (status_persona,id_accidente,cedula_persona,placa_vehiculo,roles,medicos_id_medico,citas_peritos_id_cita,remolques_id_remolque) VALUES ";
        $this->query.="('$this->status_persona','$this->id_accidente','$this->cedula_persona','$this->placa_vehiculo','$this->roles','$this->medicos_id_medico','$this->citas_peritos_id_cita','$this->remolques_id_remolque');";
        echo "query insertar: " . $this->query . "</br>";
        $this->execute_single_query();
    }
     function delete($key) {

        $this->query = '';
        $this->query = "DELETE FROM detalle_accidentes WHERE id_accidente='$key'";
        echo "query eliminar: " . $this->query . "</br>";
        $this->execute_single_query();
    }
    
    function update($key) {
        $this->query = '';
        $this->query = "UPDATE  detalle_accidentes SET id_accidente='$this->id_accidente',";
        $this->query.=" status_persona='$this->status_persona', cedula_persona='$this->cedula_persona', placa_vehiculo='$this->placa_vehiculo',";
        $this->query.=" roles='$this->roles', medicos_id_medico='$this->medicos_id_medico', citas_peritos_id_cita='$this->citas_peritos_id_cita', remolques_id_remolque='$this->remolques_id_remolque' WHERE  id_accidente='$key'";
        
        echo "query actualizar: " . $this->query . "</br>";
        $this->execute_single_query();
    }
    
    function get($key) {
        if ($key != ''):
            $this->query = "SELECT *FROM detalle_accidentes WHERE id_accidente = '$key'";
            echo "query: " . $this->query;
            $this->get_results_from_query();
        endif;
        if (count($this->rows) == 1):
            foreach ($this->rows[0] as $propiedad => $valor):
                $this->$propiedad = $valor;
            endforeach;
        endif;
    }

}
?>
